#ifndef GENERICLISTMODEL_H
#define GENERICLISTMODEL_H

#include <QAbstractListModel>
#include <QMetaObject>
#include <QQmlListProperty>
#include <QList>

class GenericListModel : public QAbstractListModel
{
    Q_OBJECT
    Q_PROPERTY(QObject* parent READ parent WRITE setParent)
public:
    explicit GenericListModel(QObject *parent = 0, QMetaObject *metaObject = 0);
    ~GenericListModel();

    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant data(const QModelIndex &index, int role) const;
    QHash<int, QByteArray> roleNames() const;

    void setEntries(const QList<QObject *> &entries);
    Q_INVOKABLE QList<QObject *> getEntries();

    QObject* parent();
    void setParent(QObject *parent);

public slots:

private:
    void clearEntries();

    QList<QObject *> m_entries;
    QHash<int, QByteArray> roles;
};

#endif // GENERICLISTMODEL_H
